package adke.managers;

import adke.models.Player;
import adke.models.powerups.AbilityPowerup;
import adke.models.powerups.Powerup;
import adke.models.powerups.PropertyPowerup;
import java.util.Vector;

// een manager voor powerups van gebruikers

// een speler kan unlimited property powerups hebben,
// maar slechts één abilitypowerup

// maar dit kunnen we nog laten instellen

public class PlayerPowerupManager
{
    private Vector<PropertyPowerup> propertyPowers;
    private Vector<AbilityPowerup> abilityPowers;
    
    public PlayerPowerupManager()
    {
        propertyPowers = new Vector();
        abilityPowers = new Vector();
    }
    
    public AbilityPowerup getAbilityPowerup()
    {
        return abilityPowers.get(0);
    }
    
    public boolean hasAbilityPowerup()
    {
        return !abilityPowers.isEmpty();
    }
    
    public void addPowerup(Powerup p)
    {
        if (p instanceof PropertyPowerup)
        {
            PropertyPowerup pp = (PropertyPowerup) p;
            propertyPowers.add(pp);
            
            // ACTIVATE POWERUP!!
            pp.activate();
        }
        else if (p instanceof AbilityPowerup)
        {
            // deactiveer actieve abilities
            if (!abilityPowers.isEmpty())
                abilityPowers.get(0).deactivate();
            
            abilityPowers.clear();
            abilityPowers.add((AbilityPowerup) p);
        }
    }
    
    public void deactivate()
    {
        for (AbilityPowerup ap : abilityPowers)
            ap.deactivate();
    }
    
    public void trashPowerup(AbilityPowerup power)
    {
        abilityPowers.remove(power);
        abilityPowers.trimToSize();
    }
}
